package com.chenjun.core.dao.generator.mapper;

import com.chenjun.core.dao.generator.entity.SysArea;
import com.chenjun.core.dao.generator.entity.SysAreaExample;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface SysAreaMapper {
    @Delete({
        "delete from sys_area",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into sys_area (id, name, ",
        "code, parent_id, ",
        "parent_ids, sort_index, ",
        "disabled, level, is_delete)",
        "values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{code,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, ",
        "#{parentIds,jdbcType=VARCHAR}, #{sortIndex,jdbcType=INTEGER}, ",
        "#{disabled,jdbcType=CHAR}, #{level,jdbcType=VARCHAR}, #{isDelete,jdbcType=CHAR})"
    })
    @SelectKey(statement="SELECT replace(UUID(), '-', '')", keyProperty="id", before=true, resultType=String.class) 
    int insert(SysArea record);

    int insertSelective(SysArea record);

    List<SysArea> selectByExample(SysAreaExample example);

    @Select({
        "select",
        "id, name, code, parent_id, parent_ids, sort_index, disabled, level, is_delete",
        "from sys_area",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    SysArea selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(SysArea record);

    @Update({
        "update sys_area",
        "set name = #{name,jdbcType=VARCHAR},",
          "code = #{code,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=VARCHAR},",
          "parent_ids = #{parentIds,jdbcType=VARCHAR},",
          "sort_index = #{sortIndex,jdbcType=INTEGER},",
          "disabled = #{disabled,jdbcType=CHAR},",
          "level = #{level,jdbcType=VARCHAR},",
          "is_delete = #{isDelete,jdbcType=CHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(SysArea record);
}